@extends('admin.common.base-master')

@section('html-head')

@endsection

@section('html-body')
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="">关于我们</a>
        </div>

        <!--二级目录-->
        @include('admin.common.banner-header')
        <div class="filter-box clearfix">

            <div class="fr">
                <a class="addBtn" href="{{route("Admin.Home.projectSet")}}">新增</a>
            </div>
        </div>
        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>标题</th>
                    <th>描述</th>
                    <th>图片</th>
                    <th>内容</th>
                    <th>链接</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @if($projectInfo)
                    <tr id="banner_{{$projectInfo->id}}">
                        <td>{{$projectInfo->id}}</td>
                        <td>{{$projectInfo->title}}</td>
                        <td>{{$projectInfo->desc}}</td>
                        <td class="account-td" style="width: 5%;">
                    <span class="photo" style="border-radius: 100%;display:initial">
                        @if($projectInfo->img_id !== 0)
                            <a href="javascript:void(0);" class="openimg" data-key="{{$projectInfo->img_id}}"><img src="{{$projectInfo->img_url}}" alt="{{$projectInfo->img_url}}"></a>
                        @else
                            <img src="{{url('images/default-avatar.png')}}" alt="">
                        @endif
                    </span>
                        </td>
                        <td>{{$projectInfo->content}}</td>
                        <td>{{$projectInfo->link_url}}</td>
                        <td><a class="color2" href="{{route("Admin.Home.projectSet")}}?id={{$projectInfo->id}}">编辑</a>
                        <span>|</span> <a href="javascript:void(0);" class="del" data-id="{{$projectInfo->id}}">删除 </a></td>
                    </tr>
                @endif
                </tbody>
            </table>
        </div>
    </div>



    <script>
        $(document).on("click",".del",function(){
            var id = $(this).attr("data-id");

            noty({
                text: '你确定要删除吗?',
                buttons: [
                    {addClass: 'btn btn-primary', text: '确定', onClick: function($noty) {
                            $noty.close();
                            $.ajax({
                                url:'{{route('Api.Admin.sys.delProject')}}',
                                type:'post',
                                dataType:'json',
                                data:{id:id},
                                success:function(obj){
                                    if(obj.level == "success"){
                                        $("#banner_"+id).hide('slow');
                                    }else{
                                        noty({type:obj.level,text:obj.message,timeout:600});
                                    }
                                },
                                error:function(obj){
                                    console.log(obj);
                                }

                            });
                        }
                    },
                    {addClass: 'btn btn-danger', text: '取消', onClick: function($noty) {
                            $noty.close();
                        }
                    }
                ]
            });

        });


    </script>
@endsection